package utils;

import java.text.DecimalFormat;

/**
 * This class represents element of fuzzy set. Value of element and value of membership function.
 * @author adam.taciak
 *
 */
public class Element implements Comparable {
	public double e;
	public double v;
	
	public Element() {
		e = 0.0;
		v = 0.0;
	}
	
	public Element(double e, double v) {
		this.e = e;
		this.v = v;
	}
	
	public String toString() {
		DecimalFormat twoDForm = new DecimalFormat("#.##");
		return twoDForm.format(v) + "/" + twoDForm.format(e);
		//return v + "/" + e;
	}

	@Override
	public int compareTo(Object o) {
		int compare = 0;
		
		Element element = (Element) o;
		
		if (element.e > e) {
			compare = -1;
		} else if (element.e < e) {
			compare = 1;
		} else {
			compare = 0;
		}
		
		return compare;
	}
}
